//
//  Vertex.m
//  Test
//
//  Created by 杨德龙 on 15/11/29.
//  Copyright © 2015年 ___杨德龙___. All rights reserved.
//

#import "Vertex.h"

@implementation Vertex

@synthesize location=location_;
@dynamic color,size;

- (id)initWithLocation:(CGPoint)location
{
    self=[super init];
    if (self) {
        [self setLocation:location];
    }
    return self;
}

// default properties do nothing
- (void)setColor:(UIColor *)color{}
- (UIColor *)color{ return nil;}

- (void)setSize:(CGFloat)size{}
- (CGFloat)size{ return  0.0;}

- (void)addMark:(id<Mark>)mark
{
    
}
- (void)removeMark:(id<Mark>)mark
{
    
}

- (id<Mark>)childMarkAtIndex:(NSUInteger )index;
{
    return nil;
}

- (id<Mark>)lastChild{
    return nil;
}

- (NSUInteger)count{
    return 0;
}
//
- (NSEnumerator *)enumerator
{
    return nil;
}
#pragma mark ---- visitor pattern
- (void)acceptMarkVisitor:(id<MarkVisitor>)visitor
{
    [visitor visitVertex:self];
}

#pragma mark -
#pragma mark -NSCopying method
- (id)copyWithZone:(NSZone *)zone
{
    Vertex *vertexCopy=[[[self class] allocWithZone:zone] initWithLocation:location_];
    return vertexCopy;
    
}

#pragma mark - NSCoder methods
- (instancetype)initWithCoder:(NSCoder *)aDecoder
{
    if (self = [super init]) {
         location_ = [(NSValue *)[aDecoder decodeObjectForKey:@"VertexLocation"] CGPointValue];
    }
    return self;
}

- (void)encodeWithCoder:(NSCoder *)aCoder
{
    [aCoder encodeObject:[NSValue valueWithCGPoint:location_] forKey:@"VertexLocation"];
}

#pragma mark - MarkIterator methods
- (void)enumerateMarksUsingBlock:(void (^)(id<Mark>, BOOL *))block
{
    
}

#pragma mark - an extended direct-draw example
// for a direct draw example
- (void) drawWithContext:(CGContextRef)context
{
    CGFloat x = self.location.x;
    CGFloat y = self.location.y;
    
    CGContextAddLineToPoint(context, x, y);
}










@end
